import { useEffect, useState } from "react"
import type { ChannelItem } from "@/apis/list"
import { fetchChannelListAPI } from "@/apis/list"

function useTabs() {
  const [channels, setChannels] = useState<ChannelItem[]>([])

  useEffect(() => {
    const getChannels = async () => {
      try {
        const res = await fetchChannelListAPI()
        setChannels(res.data.data.channels)
      } catch (error) {
        throw new Error('fetch channel error')
      }
    }
    getChannels()
  }, [])
  
  return {channels}
}

export {useTabs}